package com.scope;

import org.springframework.beans.factory.FactoryBean;

/**
 * @author wanghp
 * @version 1.0
 * @date 2020/11/4 9:42
 */
public class UserFactoryBean implements FactoryBean<UserModel> {
	int count = 1;

	/**
	 * doGetObjectFromFactoryBean
	 *
	 * @return
	 * @throws Exception
	 */
	@Override
	public UserModel getObject() throws Exception {
		UserModel userModel = new UserModel();
		userModel.setName("我是通过FactoryBean创建的第" + count++ + "对象");
		return userModel;
	}

	@Override
	public Class<?> getObjectType() {
		return UserModel.class;
	}

	@Override
	public boolean isSingleton() {
		return true;
	}
}
